<?php

namespace App\Http\Requests\examine;

use App\Http\ValidateResult;
use Illuminate\Support\Facades\Validator;

trait ConfigRequest
{
    public static function add_check(array $params): ValidateResult {
        $validator = Validator::make($params, [
            'examine_type' => 'required|integer|in:1,2,3',
            'examine_staff_id' => 'required|array',
            'copy_staff_id' => 'required|array',
        ], [
            'examine_type.required' => '请选择审核类型',
            'examine_staff_id.required' => '请选择审核人员',
            'copy_staff_id.required' => '请选择抄送人员',
        ]);

        if ($validator->fails()) {
            return ValidateResult::error($validator->errors()->first());
        }
        return ValidateResult::correct();
    }

    public static function examine_process_check(array $params): ValidateResult {
        $validator = Validator::make($params, [
            'type' => 'required|integer|in:1,2,3,4,5,6',
        ], [
            'type.required' => '请选择业务类型',
        ]);

        if ($validator->fails()) {
            return ValidateResult::error($validator->errors()->first());
        }
        return ValidateResult::correct();
    }

}
